/*
 * con_state.h
 *
 *  Created on: Sep 17, 2010
 *      Author: khanton
 */

#ifndef CON_STATE_H_
#define CON_STATE_H_

#include <boost/date_time/posix_time/posix_time.hpp>

struct con_state
{
	typedef unsigned int controller_id;
	typedef unsigned char byte;
	
	typedef struct
	{
	  byte sign_;
	  byte rtc_hour_;
	  byte rtc_min_;
	  byte rtc_sec_;
	  byte rtc_day_;
	  byte rtc_month_;
	  byte rtc_year_;
	  byte rtc_day_of_week_;
	
	  byte flash_status_;
	  byte job_mode_;
	
	  byte current_program_;
	  byte current_phase_;
	
	  byte fault_type_;
	  byte fault_red_;
	  byte fault_yellow_;
	  byte fault_green_;
	
	  byte no_programm_;
	  byte phase_time_;
	  
	  char reserv_[9];
	
	} status_packet_t;

	bool have_active_connection_;
	time_t last_access_time_;
	
	byte rtc_hour_;
	byte rtc_min_;
	byte rtc_sec_;
	byte rtc_day_;
	byte rtc_month_;
	byte rtc_year_;
	byte rtc_day_of_week_;
	
	byte flash_status_;
	byte job_mode_;
	
	byte current_program_;
	byte current_phase_;
	
	byte fault_type_;
	byte fault_red_;
	byte fault_yellow_;
	byte fault_green_;
	
	byte no_programm_;
	byte phase_time_;
	
	con_state();
	virtual ~con_state();
	
	void operator = (const con_state::status_packet_t &_state);
	void setup_packet(con_state::status_packet_t &_state);
	
	boost::posix_time::ptime as_local_time() const; 
};

#endif /* CON_STATE_H_ */
